package behaviour.building;

import jade.core.behaviours.CyclicBehaviour;
import jade.lang.acl.ACLMessage;
import jade.lang.acl.MessageTemplate;

public class ReceiveMoveRequestBehaviour extends CyclicBehaviour {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8086531916604630595L;

	@Override
	public void action() {
		int nbPropag;
		MessageTemplate mt = MessageTemplate.MatchConversationId("start-propagation");
		ACLMessage msg = myAgent.receive(mt);
		if(msg != null) {
			nbPropag = Integer.parseInt(msg.getContent());
			myAgent.addBehaviour(new RequestMoveBehaviour("", nbPropag, msg.getReplyWith(), msg.getSender()));
		}
		else
			block();

	}

}
